package com.eco.fanliapp.controller.app;

import com.eco.fanliapp.common.base.BaseController;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.dataoke.DaTaoKeItemInfoService;
import com.eco.fanliapp.service.ITaoBaoService;
import com.eco.fanliapp.vo.ShopMessage;
import com.eco.fanliapp.vo.respone.DTKResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @date 2019-09-20
 */
@Controller
@RequestMapping("/mobile/home")
public class DaTaoKeController extends BaseController {

    @Autowired
    private ITaoBaoService iTaoBaoService;

    @Autowired
    private DaTaoKeItemInfoService daTaoKeItemInfoService;
    /**
     * 热搜
     * @return
     */
    @GetMapping("/dtk/hotSearch")
    @ResponseBody
    public ServerResponse dtkHotSearch() {
        return iTaoBaoService.dtkHotSearch();
    }

    /**
     * 店铺信息
     * @return
     */
    @GetMapping("/dtk/shopMessage")
    @ResponseBody
    public ServerResponse shop(String itemId) {

        DTKResponse dtkResponse = daTaoKeItemInfoService.itemInfoByItemId(itemId);
        ShopMessage shopMessage=new ShopMessage();
        if (dtkResponse != null && dtkResponse.getCode() == 0 && dtkResponse.getData() != null) {
            DTKResponse.DataBean data=dtkResponse.getData();
            shopMessage.setShopName(data.getShopName());
            shopMessage.setDescScore(data.getDescScore());
            shopMessage.setDsrPercent(data.getDsrPercent());
            shopMessage.setServicePercent(data.getServicePercent());
            shopMessage.setServiceScore(data.getServiceScore());
            shopMessage.setShopLevel(data.getShopLevel());
            shopMessage.setShipPercent(data.getShipPercent());
            shopMessage.setShipScore(data.getShipScore());
            return ServerResponse.createBySuccess(200,"店铺信息查询成功",shopMessage);
        }else{
            return ServerResponse.createBySuccessCodeMessage(201,"没有店铺信息");
        }

    }



}
